<?php

/**
 * This is the model class for table "transmigrasi".
 *
 * The followings are the available columns in table 'transmigrasi':
 * @property integer $tr_id
 * @property integer $id_kecamatan
 * @property integer $tlkk
 * @property integer $tljiwa
 * @property integer $tukk
 * @property integer $tujiwa
 * @property integer $pirkk
 * @property integer $pirjiwa
 * @property integer $jumlahkk
 * @property integer $jumlahjiwa
 * @property integer $tahun
 *
 * The followings are the available model relations:
 * @property Kecamatan $idKecamatan
 */
class Transmigrasi extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Transmigrasi the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'transmigrasi';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_kecamatan, tlkk, tljiwa, tukk, tujiwa, pirkk, pirjiwa, jumlahkk, jumlahjiwa, tahun', 'numerical', 'integerOnly'=>true),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('tr_id, id_kecamatan, tlkk, tljiwa, tukk, tujiwa, pirkk, pirjiwa, jumlahkk, jumlahjiwa, tahun', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'idKecamatan' => array(self::BELONGS_TO, 'Kecamatan', 'id_kecamatan'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'tr_id' => 'Tr',
			'id_kecamatan' => 'Id Kecamatan',
			'tlkk' => 'Tlkk',
			'tljiwa' => 'Tljiwa',
			'tukk' => 'Tukk',
			'tujiwa' => 'Tujiwa',
			'pirkk' => 'Pirkk',
			'pirjiwa' => 'Pirjiwa',
			'jumlahkk' => 'Jumlahkk',
			'jumlahjiwa' => 'Jumlahjiwa',
			'tahun' => 'Tahun',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('tr_id',$this->tr_id);
		$criteria->compare('id_kecamatan',$this->id_kecamatan);
		$criteria->compare('tlkk',$this->tlkk);
		$criteria->compare('tljiwa',$this->tljiwa);
		$criteria->compare('tukk',$this->tukk);
		$criteria->compare('tujiwa',$this->tujiwa);
		$criteria->compare('pirkk',$this->pirkk);
		$criteria->compare('pirjiwa',$this->pirjiwa);
		$criteria->compare('jumlahkk',$this->jumlahkk);
		$criteria->compare('jumlahjiwa',$this->jumlahjiwa);
		$criteria->compare('tahun',$this->tahun);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}